package HomeWork01;

public class Test01 {
    public static void main(String[] args) {
        Book a[]=new Book[5];
        a[0]=new Book(1,"a","aa",10.0,1,1);
        a[1]=new Book(2,"b","bb",20.0,2,2);
        a[2]=new Book(1,"c","cc",30.0,3,3);
        a[3]=new Book(1,"d","dd",40.0,4,4);
        a[4]=new Book(1,"e","ee",50.0,5,5);
        for(int j=0;j<4;j++){
            for(int i=j;i<4;i++){
                if(a[i].getSales()<a[i+1].getSales()){
                    Book temp=a[i];
                    a[i]=a[i+1];
                    a[i+1]=temp;
                }
            }
        }
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i].getId()+a[i].getTitle()+a[i].getAuthor()+a[i].getPrice()+a[i].getSales()+a[i].getStock());
        }
    }
}
//
class Book{
    private int id;
    private String title;
    private String author;
    private double price;
    private int sales;
    private int stock;

    public Book(int id, String title, String author, double price, int sales, int stock) {
        this.id = id;
        this.title = title;
        this.author = author;
        this.price = price;
        this.sales = sales;
        this.stock = stock;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getSales() {
        return sales;
    }

    public void setSales(int sales) {
        this.sales = sales;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }
}
